#include "Address.h"

using namespace network;

Address::Address(const char *ip, unsigned short port) {
    address_.sin_family = AF_INET;
    address_.sin_addr.s_addr = inet_addr(ip);
    address_.sin_port = htons(port);
}

void Address::setIp(const char *ip) {
    address_.sin_addr.s_addr = inet_addr(ip);
}

void Address::setPort(unsigned short port) {
    address_.sin_port = htons(port);
}

unsigned short Address::getPort() const {
    return ntohs(address_.sin_port);
}

std::string Address::getIp() const {
    return {inet_ntoa(address_.sin_addr)};
}
